package ${basePackageName}.interfaces.feign;

<#if common>
import com.zy.explore.common.interfaces.frm.CommonIdFrm;
import com.zy.explore.common.interfaces.frm.CommonIdsFrm;
import com.zy.explore.common.interfaces.vo.PageVO;
<#else>
import ${basePackageName}.interfaces.frm.CommonIdFrm;
import ${basePackageName}.interfaces.frm.CommonIdsFrm;
import ${basePackageName}.interfaces.vo.PageVO;
</#if>
import ${basePackageName}.infrastructure.constant.Router;
import ${basePackageName}.infrastructure.constant.ProjectConstant;
import ${basePackageName}.interfaces.frm.${tableClassNamePrefix}SaveFrm;
import ${basePackageName}.interfaces.frm.${tableClassNamePrefix}QueryFrm;
import ${basePackageName}.interfaces.vo.${tableClassNamePrefix}VO;
import ${basePackageName}.infrastructure.constant.Router;
import ${basePackageName}.infrastructure.constant.<#if prefixMp??>${prefixMp}</#if>${tableClassNamePrefix}Router;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import org.springframework.validation.annotation.Validated;
import java.util.List;

/**
 * description 表(${tableName})对应mybatis-plus的Feign
 *
 * @author ${authorName}
 * @date ${dateTime}
 */
@FeignClient(value = ProjectConstant.APPLICATION_NAME, path = <#if prefixMp??>${prefixMp}</#if>${tableClassNamePrefix}Router.${tableNameUpperCaseUnderline}, contextId = ProjectConstant.APPLICATION_NAME + ".<#if prefixMp??>${prefixMp}</#if>${tableClassNamePrefix}Feign")
public interface <#if prefixMp??>${prefixMp}</#if>${tableClassNamePrefix}Feign {

    /**
     * 新增数据
     *
     * @param frm 待新增的Frm对象
     * @return 成功返回新增后的VO对象，失败返回null
     */
    @ApiOperationSupport(order = 10, author = "${authorName}", ignoreParameters = {"id"})
    @ApiOperation("①新增数据")
    @PostMapping(Router.INSERT)
    ${tableClassNamePrefix}VO insert(@RequestBody @Validated ${tableClassNamePrefix}SaveFrm frm);

    /**
     * 删除数据
     *
     * @param frm 主键Frm对象
     * @return 1:删除成功 其他:删除失败
     */
    @ApiOperationSupport(order = 20, author = "${authorName}")
    @ApiOperation("②删除数据")
    @PostMapping(Router.DELETE)
    Integer delete(@RequestBody @Validated CommonIdFrm frm);

    /**
     * 更新数据
     *
     * @param frm 待更新的Frm对象
     * @return 成功返回更新后的VO对象，失败返回null
     */
    @ApiOperationSupport(order = 30, author = "${authorName}")
    @ApiOperation("③更新数据")
    @PostMapping(Router.UPDATE)
    ${tableClassNamePrefix}VO update(@RequestBody @Validated ${tableClassNamePrefix}SaveFrm frm);

    /**
     * 通过主键查询单条数据
     *
     * @param frm 主键Frm对象
     * @return 成功返回对应ID的VO对象，查询不到返回null
     */
    @ApiOperationSupport(order = 40, author = "${authorName}")
    @ApiOperation("④根据主键查询数据")
    @PostMapping(Router.FIND_BY_ID)
    ${tableClassNamePrefix}VO findById(@RequestBody @Validated CommonIdFrm frm);

    /**
     * 通过主键集合查询多条数据
     *
     * @param frm 主键集合Frm对象
     * @return 成功返回对应ID的VO对象，查询不到返回null
     */
    @ApiOperationSupport(order = 50, author = "${authorName}")
    @ApiOperation("⑤根据主键集批量查询数据")
    @PostMapping(Router.FIND_BY_IDS)
    List<${tableClassNamePrefix}VO> findByIds(@RequestBody @Validated CommonIdsFrm frm);

    /**
     * 根据条件获取数据集
     *
     * @param frm 查询条件对象
     * @return 满足条件的数据集合,非null
     */
    @ApiOperationSupport(order = 60, author = "${authorName}", ignoreParameters = {"pageNum", "pageSize"})
    @ApiOperation("⑥根据条件查询数据集")
    @PostMapping(Router.FIND_LIST)
    List<${tableClassNamePrefix}VO> findList(@RequestBody @Validated ${tableClassNamePrefix}QueryFrm frm);

    /**
     * 根据条件查询数据分页
     *
     * @param frm 查询条件参数
     * @return 成功返回满足条件的分页，非null
     */
    @ApiOperationSupport(order = 70, author = "${authorName}")
    @ApiOperation("⑦根据条件查询数据分页")
    @PostMapping(Router.FIND_PAGE)
    PageVO<${tableClassNamePrefix}VO> findPage(@RequestBody @Validated ${tableClassNamePrefix}QueryFrm frm);

}
